#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_QtChatExample.h"

class QtChatExample : public QMainWindow
{
	Q_OBJECT

public:
	QtChatExample(QWidget *parent = Q_NULLPTR);

private slots:
	void Inputing();
	void slider();
	void RemoteInputing();
	void LocalInputing();
	void RemoteSent(QString data);
	void LocalSent(QString data);

private:
	void handle_GET(http_request request);
	void handle_POST(http_request request);
private slots:
	void handle_Response(QNetworkReply *reply);

private:
	Ui::QtChatExampleClass ui;

	system_clock::time_point m_lastInputTime;
private:
	optional<QString> m_szLocalAddress;
	optional<QString> m_szRemoteAddress;
	http_listener m_listener;
	unique_ptr<QNetworkAccessManager> m_mgr;

	static const QString szInputing;
	static const QString szSend;
	static const std::size_t iLimit;

signals:
	void RemoteInputingEvent();
	void LocalInputingEvent();
	void RemoteSentEvent(QString);
	void LocalSentEvent(QString);
};
